package com.everyday.practice.algorithm;

import java.io.*;

/**
 * @description:
 * @author: leon
 * @time: 2021/4/7 10:50
 */
public class Title1 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        int[] demo1={1};
        int[] demo2=demo1;
        demo2[0]=demo1[0];
        int[] demo3 =(int[])deepClone(demo1);
        System.out.println(demo2);
        System.out.println(demo3==demo1);
    }

    public int[] twoSum(int[] nums, int target) {
        for (int i=0;i<nums.length;i++){

        }
        return null;
    }
    //深度复制
    public static Object deepClone(Object obj) throws IOException, ClassNotFoundException {
        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        ObjectOutputStream oos=new ObjectOutputStream(bos);
        oos.writeObject(obj);

        ByteArrayInputStream bis=new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream ois=new ObjectInputStream(bis);
        return ois.readObject();
    }
}
